using System;
using PickGold.Charting;

namespace PickGold.Charting.Formulas
{
	internal class ForecastingFormulaInfo : FormulaInfo
	{
		private string _parameters;

		public ForecastingFormulaInfo()
			: this(TimeSeriesAndForecasting.RegressionType.Polynomial, 2, 0, true, true)
		{
		}

		public ForecastingFormulaInfo(TimeSeriesAndForecasting.RegressionType regressionType, int polynomialDegree, int forecastingPeriod, bool returnApproximationError, bool returnForecastingError)
			: base(new DataField[] { DataField.Close }, new DataField[] { DataField.Close, DataField.High, DataField.Low }, new object[] { regressionType, polynomialDegree, forecastingPeriod, returnApproximationError, returnForecastingError })
		{
		}

		internal override void CheckParameterString(string parameters)
		{
			if (!string.IsNullOrEmpty(parameters))
			{
				string[] strArray = parameters.Split(new char[] { ',' });
				int num = 1;
				for (int i = 2; (i < base.Parameters.Length) && (num < strArray.Length); i++)
				{
					string str = strArray[num++];
					if (!string.IsNullOrEmpty(str))
					{
						try
						{
							this.ParseParameter(i, str);
						}
						catch (FormatException)
						{
							throw new ArgumentException(SR.ExceptionFormulaDataFormatInvalid(parameters));
						}
					}
				}
			}
		}

		internal override void LoadParametersFromString(string parameters)
		{
			this._parameters = parameters;
		}

		internal override string SaveParametersToString()
		{
			if (string.IsNullOrEmpty(this._parameters))
			{
				return this._parameters;
			}
			return "2,0,true,true";
		}
	}
}

